#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int cowx;
    int cowy;
    int fx;
    int fy;
    //freopen("in.txt","r",stdin);
    char trees[15][15];
    int count = 0;
    for(int i = 1; i <= 10; i++)
    {
        for(int j = 1; j <= 10; j++)
        {
            cin >> trees[i][j];
            if(trees[i][j] == 'F')
            {
                fy = i;
                fx = j;
            }
            if(trees[i][j] == 'C')
            {
                cowy = i;
                cowx = j;
            }
        }
    }
    int cow = 0;
    int f = 0;
    while (cowx != fx || cowy != fy)
    {
        if(cow == 0)
        {
            if(cowy == 1 || trees[cowy-1][cowx] == '*')
            {
                cow = 1;
            }
            else
            {
                cowy--;
            }
        }
        else
        if(cow == 1)
        {
            if(cowx == 10 || trees[cowy][cowx+1] == '*')
            {
                cow = 2;
            }
            else
            {
                cowx++;
            }
        }
        else
        if(cow == 2)
        {
            if(cowy == 10 || trees[cowy+1][cowx] == '*')
            {
                cow = 3;
            }
            else
            {
                cowy++;
            }
        }
        else
        if(cow == 3)
        {
            if(cowx == 1 || trees[cowy][cowx-1] == '*')
            {
                cow = 0;
            }
            else
            {
                cowx--;
            }
        }

        if(f == 0)
        {
            if(fy == 1 || trees[fy-1][fx] == '*')
            {
                f = 1;
            }
            else
            {
                fy--;
            }
        }
        else
        if(f == 1)
        {
            if(fx == 10 || trees[fy][fx+1] == '*')
            {
                f = 2;
            }
            else{
                fx++;
            }
        }
        else
        if(f == 2)
        {
            if(fy == 10 || trees[fy+1][fx] == '*')
            {
                f = 3;
            }
            else
            {
                fy++;
            }
        }
        else
        if(f == 3)
        {
            if(fx == 1 || trees[fy][fx-1] == '*')
            {
                f = 0;
            }
            else
            {
                fx--;
            }
        }
        count++;
        if(count > 100000) break;
        if(count <=49)
        {
            //printf("%d %d %d %d\n",cowx,cowy,fx,fy);
            //printf("%d %d\n",fx,fy);
        }
    }
    if(count > 100000) cout << "0";
    else cout << count;
    
}